package main

import (
	"gorule/core"
	"log"
)

func main(){
	ctx := core.NewContext()
	rule1 := core.Rule(
		func(ctx *core.Context) bool {
			return false
		},
		func(ctx *core.Context){
			log.Println("rule1")
		},
	)
	rule2 := core.Rule(
		func(ctx *core.Context) bool {
			return true
		},
		func(ctx *core.Context){
			log.Println("rule2")
		},
	)
	rule1.Execute(&ctx)
	rule2.Execute(&ctx)

	rule3 := core.AndRule(
		rule1,
		rule2,
	)
	ctx = core.NewContext()
	rule3.Execute(&ctx)

	rule4 := core.AndRule(
		core.Rule(
			func(ctx *core.Context) bool {
				return true
			},
			func(ctx *core.Context) {},
		),
		core.Rule(
			func(ctx *core.Context) bool {
				return true
			},
			func(ctx *core.Context) {
				log.Println("rule4")
			},
		),
	)
	rule4.Execute(&ctx)

}
